<template>
	<view class="themeItem">
		<navigator class="box" :url="'/pages/classlist/classlist?id='+item._id+'&name='+item.name" v-if="!isMore">
			<image class="pic" :src="item.picurl" mode="aspectFill"></image>
			<view class="mask">{{item.name}}</view>
			<view class="tab" v-if="formatTimestamp(item.updateTime)">{{formatTimestamp(item.updateTime)}}</view>
		</navigator>
		<navigator class="box more" url="/pages/classify/classify" open-type="reLaunch" v-else>
			<image class="pic" src="/common/images/more.jpg" mode="aspectFill"></image>
			<view class="mask">
				<uni-icons type="more-filled" size="34" color="#fff"></uni-icons>
				<view class="text">更多</view>
			</view>
		</navigator>
	</view>
</template>

<script setup>
import {formatTimestamp} from '@/utils/common.js'

/* 
声明props接收参数:
isMore：渲染哪个结构
item:父组件传递过来的对象（default定义了一个默认对象） 
*/
defineProps({
	isMore:{
		type:Boolean,
		default:false
	},
	item:{
		type:Object,
		default(){
			return {
				name:"默认名称",
				picurl:"/common/images/classify1.jpg",
				updateTime:Date.now()-1000*60*5
			}
		}
	}
})
</script>

<style lang="scss" scoped>
.themeItem{
	.box{
		height: 340rpx;
		//内部有图片，父级加圆角时需要配合overflow:hidden使用
		border-radius: 10rpx;
		overflow: hidden;
		position: relative;
		.pic{
			width: 100%;
			height: 100%;
		}
		.mask{
			//盒子模型
			width: 100%;
			height: 70rpx;
			//文字
			color:#fff;
			font-size:30rpx;
			font-weight: 600;
			//定位
			position: absolute;
			left: 0;
			bottom: 0;
			//磨砂效果
			background:rgba(0, 0, 0, .2);
			backdrop-filter: blur(20rpx);
			//弹性布局
			display: flex;
			align-items: center;
			justify-content: center;
		}
		.tab{
			//盒子模型
			padding: 6rpx 14rpx;
			//文字
			color:#fff;
			font-size: 22rpx;
			//定位
			position: absolute;
			left: 0;
			top: 0;
			//磨砂效果
			background: rgba(250,129,90,0.7);
			backdrop-filter: blur(20rpx);
			//圆角
			border-radius: 0 0 20rpx 0;	
			//文字大小再进行缩放
			transform-origin: left top;
			transform: scale(0.8);
		}
	}
	.box.more{
		.mask{
			width: 100%;
			height: 100%;
			flex-direction: column;
			.text{
				font-size: 28rpx;
			}	
		}
	}
}
</style>